package org.example.session;

import lombok.Data;
import org.dom4j.DocumentException;
import org.example.config.Configurations;
import org.example.service.DatasourceXml;
import org.example.service.XmlBuilderService;
import org.springframework.stereotype.Component;

import javax.annotation.PostConstruct;
import java.beans.PropertyVetoException;

@Data
public class SessionInit {


    public static Configurations init() throws DocumentException, PropertyVetoException {
        Configurations configuration = new Configurations();

        //解析xml mapper
        XmlBuilderService xmlBuilderService = new XmlBuilderService(configuration);
        xmlBuilderService.parse();
        //数据库配置
        DatasourceXml datasourceXml = new DatasourceXml(configuration);
        datasourceXml.parse();

        //配置完之后，开始容器的创建，将所有的mapper进行封装，生成代理
        //通过返回bean对象将代理对象都交给bean容器管理
        return configuration;


    }
}
